<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Import {

    /**
     * 
     * @param type $string
     * @return int
     */
    private function _convertMoney($string = '') {
        $string = rtrim($string, '円');
        if (is_numeric($string)) {
            return $string;
        }
        if (strpos($string, '万') !== false) {
            $arr = explode('万', $string);
            if (!empty($arr)) {
                return 10000 * $arr[0] + (int) @$arr[1];
            }
        }
        return 0;
    }

    /**
     * 
     * @param type $arr
     * @return type
     */
    public function import($arr = array()) {
        if (empty($arr)) {
            return;
        }
        global $database, $user;
        $date = date('Y-m-d H:i:s');
        mb_language("japanese");           //言語(日本語)
        mb_internal_encoding("UTF-8");
       
        foreach ($arr as $value) {
            try {
                if (empty($value) || !is_array($value)) {
                    continue;
                }
               
                $database->database_query(" INSERT IGNORE INTO transaction_parameter (
                                contract_code,
                                house_name,
                                house_address,
                                house_address_2,
                                room_number,
                                client_name,
                                client_phone,    
                                guarantee_company_name
                              ) VALUES (
                                '{$value['contract_code']}',
                                '{$value['house_name']}',
                                '{$value['house_address']}',
                                '{$value['house_address_2']}',
                                '{$value['room_number']}',
                                '{$value['client_name']}',
                                '{$value['client_phone']}',
                                '{$value['guarantee_company_name']}'
                              )
                            ");
            } catch (Exception $ex) {
                continue;
            }
        }
    }

}
